package protocol;

import org.json.simple.JSONObject;

public class HTTPResponse {
	private HTTPResponseHeaders fHTTPResponseHeaders;
	private boolean _shouldCloseConnection;

	public boolean is_shouldCloseConnection() {
		return _shouldCloseConnection;
	}

	public HTTPResponseHeaders getfHTTPResponseHeaders() {
		return fHTTPResponseHeaders;
	}

	public HTTPMSG getfHTHttpmsg() {
		return fHTHttpmsg;
	}

	private HTTPMSG fHTHttpmsg;

	public HTTPResponse(String statusCode, String HTTPVesrion,
			JSONObject headers, String msg, boolean shouldCloseConnection) {
		_shouldCloseConnection = shouldCloseConnection;
		this.fHTHttpmsg = new HTTPMSG(msg);
		this.fHTTPResponseHeaders = new HTTPResponseHeaders(statusCode,
				HTTPVesrion, headers);

	}

	@SuppressWarnings("unchecked")
	public String toString() {
		this.fHTTPResponseHeaders.getfHeaders().put(Headers.CONTENT_LENGTH,
				this.fHTHttpmsg.toString().length() + 4);
		return this.fHTTPResponseHeaders.toString()
				+ this.fHTHttpmsg.toString() + "\n$";
	}
}
